home *** CD-ROM | disk | FTP | other *** search
- property pParseScriptMember, pParseCastLibrary, pParseScriptText, pCommentRuns, pGlobalDeclarationRuns, pPropertyDeclarationRuns, pLocalDeclarationRuns, pHandlerDeclarationRuns, pPropertyVariableRuns, pGlobalVariableRuns, pLocalVariableRuns, pHandlerNameRuns, ppropertynamelist, pGlobalNameList, pLocalNameList, pHandlerNameList
-
- on new me, scriptMember, castLibrary, scriptText, handlerNamelist
- set the pParseScriptMember of me to scriptMember
- set the pParseCastLibrary of me to castLibrary
- set the pParseScriptText of me to scriptText
- set the pHandlerNameList of me to handlerNamelist
- sort(the pHandlerNameList of me)
- initProperties(me)
- return me
- end
-
- on initProperties me
- set the pCommentRuns of me to []
- set the pGlobalDeclarationRuns of me to []
- set the pPropertyDeclarationRuns of me to []
- set the pLocalDeclarationRuns of me to []
- set the pHandlerDeclarationRuns of me to []
- set the pPropertyVariableRuns of me to []
- set the pGlobalVariableRuns of me to []
- set the pLocalVariableRuns of me to []
- set the pHandlerNameRuns of me to []
- set the ppropertynamelist of me to []
- sort(the ppropertynamelist of me)
- set the pGlobalNameList of me to []
- sort(the pGlobalNameList of me)
- set the pLocalNameList of me to []
- sort(the pLocalNameList of me)
- end
-
- on parseScript me, whichOptions
- set scriptText to the pParseScriptText of me
- set nextLineStartsAt to 1
- repeat while scriptText <> EMPTY
- set scriptLine to line 1 of scriptText
- if word 1 of scriptLine starts "--" then
- set continuationLines to 1
- set continuationFlag to 1
- repeat while continuationFlag = 1
- case 1 of
- (charToNum(the last char in scriptLine) = 194):
- set continuationLines to continuationLines + 1
- set scriptLine to line continuationLines of scriptText
- (word 1 of line continuationLines + 1 of scriptText starts "--"):
- set continuationLines to continuationLines + 1
- set scriptLine to line continuationLines of scriptText
- otherwise:
- set continuationFlag to 0
- end case
- end repeat
- set runLength to length(line 1 to continuationLines of scriptText)
- set characterRunEnd to nextLineStartsAt + runLength - 1
- add(the pCommentRuns of me, [nextLineStartsAt, characterRunEnd])
- set nextLineStartsAt to characterRunEnd + 1
- delete char 1 to runLength of scriptText
- next repeat
- end if
- if scriptLine starts "end " then
- set handlerName to word 2 of scriptLine
- if handlerName <> EMPTY then
- set characterRunStart to offset(handlerName, scriptLine) + nextLineStartsAt - 1
- set characterRunEnd to characterRunStart + length(handlerName) - 1
- add(the pHandlerDeclarationRuns of me, [characterRunStart, characterRunEnd])
- end if
- set scriptLineLength to length(scriptLine) + 1
- set nextLineStartsAt to nextLineStartsAt + scriptLineLength
- delete char 1 to scriptLineLength of scriptText
- next repeat
- end if
- case word 1 of scriptLine of
- "on":
- set handlerName to word 2 of scriptLine
- set characterRunStart to offset(handlerName, scriptLine) + nextLineStartsAt - 1
- set characterRunEnd to characterRunStart + length(handlerName) - 1
- add(the pHandlerDeclarationRuns of me, [characterRunStart, characterRunEnd])
- set scriptLineLength to length(scriptLine) + 1
- set elementList to elementsData(scriptLine)
- deleteAt(elementList, 1)
- deleteAt(elementList, 1)
- set the pLocalNameList of me to []
- repeat while count(elementList) > 0
- set element to getPropAt(elementList, 1)
- set elementSymbol to symbol(element)
- set elementStartPos to getaProp(elementList, element)
- deleteAt(elementList, 1)
- add(the pLocalDeclarationRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- if getOne(the pLocalNameList of me, elementSymbol) = 0 then
- add(the pLocalNameList of me, elementSymbol)
- end if
- end repeat
- set nextLineStartsAt to nextLineStartsAt + scriptLineLength
- delete char 1 to scriptLineLength of scriptText
- next repeat
- "global":
- set characterRunStart to offset("global", scriptLine) + nextLineStartsAt - 1
- set characterRunEnd to characterRunStart + 5
- add(the pGlobalDeclarationRuns of me, [characterRunStart, characterRunEnd])
- set scriptLineLength to length(scriptLine) + 1
- set nextLineStartsAt to nextLineStartsAt + scriptLineLength
- delete word 1 of scriptLine
- set totalItems to the number of items in scriptLine
- repeat with theItem = 1 to totalItems
- add(the pGlobalNameList of me, symbol(item theItem of scriptLine))
- end repeat
- delete char 1 to scriptLineLength of scriptText
- next repeat
- "property":
- set characterRunStart to offset("property", scriptLine) + nextLineStartsAt - 1
- set characterRunEnd to characterRunStart + 7
- add(the pPropertyDeclarationRuns of me, [characterRunStart, characterRunEnd])
- set scriptLineLength to length(scriptLine) + 1
- set nextLineStartsAt to nextLineStartsAt + scriptLineLength
- delete word 1 of scriptLine
- set totalItems to the number of items in scriptLine
- repeat with theItem = 1 to totalItems
- add(the ppropertynamelist of me, symbol(item theItem of scriptLine))
- end repeat
- delete char 1 to scriptLineLength of scriptText
- next repeat
- otherwise:
- end case
- set elementList to elementsData(scriptLine)
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- repeat while count(elementList) > 0
- set element to getPropAt(elementList, 1)
- set elementSymbol to symbol(element)
- set elementStartPos to getaProp(elementList, element)
- deleteAt(elementList, 1)
- case 1 of
- (getOne(the pLocalNameList of me, elementSymbol) > 0):
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- add(the pLocalVariableRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- (getOne(the pGlobalNameList of me, elementSymbol) > 0):
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- add(the pGlobalVariableRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- (getOne(the pHandlerNameList of me, elementSymbol) > 0):
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- add(the pHandlerNameRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- (getOne(the ppropertynamelist of me, elementSymbol) > 0):
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- add(the pPropertyVariableRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- setFlag:
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- if element <> "the" then
- add(the pLocalDeclarationRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- if getOne(the pLocalNameList of me, elementSymbol) = 0 then
- add(the pLocalNameList of me, elementSymbol)
- end if
- end if
- putFlag:
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- if getOne([#cast, #char, #field, #item, #line, #member, #castLib, #sprite, #word], elementSymbol) = 0 then
- add(the pLocalDeclarationRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- if getOne(the pLocalNameList of me, elementSymbol) = 0 then
- add(the pLocalNameList of me, elementSymbol)
- end if
- end if
- withFlag:
- set setFlag to 0
- set putFlag to 0
- set withFlag to 0
- add(the pLocalDeclarationRuns of me, [nextLineStartsAt + elementStartPos - 1, nextLineStartsAt + (elementStartPos + length(element) - 2)])
- if getOne(the pLocalNameList of me, elementSymbol) = 0 then
- add(the pLocalNameList of me, elementSymbol)
- end if
- (element = "set"):
- set setFlag to 1
- set putFlag to 0
- set withFlag to 0
- (getOne([#after, #before, #into], elementSymbol) > 0):
- set setFlag to 0
- set putFlag to 1
- set withFlag to 0
- (element = "with"):
- set setFlag to 0
- set putFlag to 0
- set withFlag to 1
- end case
- end repeat
- set scriptLineLength to length(scriptLine) + 1
- set nextLineStartsAt to nextLineStartsAt + scriptLineLength
- delete char 1 to scriptLineLength of scriptText
- end repeat
- nothing()
- end
-